package com.coderman.youpinshop.stock.bo;

import com.coderman.youpinshop.stock.dataobject.StockRecordDO;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

/**
 * Description:库存变更操作日志记录对象
 * date: 2022/1/15
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Data
@Builder
public class StockRecordBO {
    /**
     * 库存编码
     */
    private String stockCode;

    /**
     * 操作类型编码
     */
    private String operationCode;

    /**
     * 操作之前的库存数量
     */
    private Integer beforQuantity;

    /**
     * 操作之后的库存数量
     */
    private Integer afterQuantity;

    /**
     * 操作时间
     */
    private Date operationDate;

    /**
     * 将bo转化为DO
     * @return StockRecordDO
     */
    public StockRecordDO convertToDO(){
        StockRecordDO stockRecordDO = new StockRecordDO();
        stockRecordDO.setStockCode(stockCode);
        stockRecordDO.setAfterQuantity(afterQuantity);
        stockRecordDO.setOperationCode(operationCode);
        stockRecordDO.setBeforeQuantity(beforQuantity);
        stockRecordDO.setOperationDate(new Date());
        return stockRecordDO;
    }


}
